/*
* @Author: chenggh
* @Date: 2025-06-18
* @Link to Problem : https://oj.haizeix.com/problem/237
*/
#include <iostream>
using namespace std;
int arr[10] = {0};
int visited[10] = {0};

void print_arr(int d){
	for(int i = 0; i <= d; i++){
		if(i) cout << " ";
		cout << arr[i];
	}cout << endl;
}


void f(int i, int j, int d){
	if(d == j - i + 1){
		print_arr(d - 1);
		return;
	}
	for(int k = i; k <= j; k++){
		if(visited[k]) continue;
		arr[d] = k;
		visited[k] = 1;
		f(i, j, d + 1);
		visited[k] = 0;
	}return;
}
int main(){
	int n; cin >> n;
	f(1, n, 0);
	return 0;
}